﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Kelper.Infrastructure.Helpers
{
    public static class StringExtensions
    {
        public static string Capitalize(this string s)
        {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < s.Length; i++)
            {
                char c = s[i];
                sb.Append(i == 0? Char.ToUpper(c) : Char.ToLower(c));
            }
            return sb.ToString();
        }

        public static string Truncate(this string s, int max, string ellipsis)
        {
            return s.Length > max ? s.Substring(0, max) + ellipsis : s;
        }
    }
}